<?php

namespace App\Observers;

use App\Models\User;
use Illuminate\Support\Facades\DB;

class UserObserver
{
    public function saving(User $user){
        if(empty($user->avatar)){
            $user->avatar = url('fakers/avatars/face14.jpg');
        }
    }
//    public function deleted(User $user){
//        DB::table('replies')->where('user_id',$user->id)->delete();
//        $topics = DB::table('topics')->where('user_id',$user->id)->get();
//        foreach ($topics as $topic){
//            DB::table('replies')->where('topic_id',$topic->id)->delete();
//        }
//        DB::table('topics')->where('user_id',$user->id)->delete();
//    }
}
